
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script type="text/javascript" src="/static/layui/layui.js"></script>
		<link rel="stylesheet" type="text/css" href="/static/css/login.css"/>
	</head>
	<body>
	<form class="layui-form">
		<div class="bg">
			<div class="wel">用户注册</div>
	        <div class="user">
	       	    <div id="yonghu" style="">手机号</div>
	       	    <input type="tel" name="phone" lay-verify="required|phone" value="" placeholder="请输入用户名" maxlength="11" />
	        </div>
	        <div class="password" >
	        	<div id="yonghu" >密&nbsp;&nbsp;&nbsp;码</div>
	       	    <input type="password" name="password" value="" placeholder="请输入密码" maxlength="30" />
	        </div>
	        <input type="hidden" name="room_id" value="{$room_id}">
	        <input class="btn" type="button"  value="注册" lay-submit lay-filter="_submit" />
		</div>
	</form>
	</body>
<script type="text/javascript">
        layui.use(['layer','form','jquery'], function(){
            var layer  = layui.layer;
            var form   = layui.form;
            var $      = layui.jquery;
            form.on('submit(_submit)', function(data){
            	if(!data.field.password)
            	{
            		layer.msg('请输入密码', {icon: 2});
                    return false;
            	}
            $.ajax({
                  url: "/account/register",
                  data: data.field,
                  type: 'post',
                  dataType: "json",
                  async: false,
                  success: function (response) {
                      if (response.code == '200') {
                        var index = parent.layer.getFrameIndex(window.name);
			            parent.layer.close(index);
			            parent.location.reload();
                      } else {
                          layer.msg(response.msg, {icon: 2});
                          return false;
                      }
                  }
            })
            return false;
          });

        })
    </script>
</html>

